<template>
  <el-form ref="formRef" :model="job" label-width="120px">
    <el-form-item label="创建者编号">
      <el-input v-model="job.createId"></el-input>
    </el-form-item>
    <el-form-item label="题目类型">
      <el-select  v-model="job.type" placeholder="请选择任务类型">
        <el-option label="考试" value="0"></el-option>
        <el-option label="作业" value="1"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="开始时间">
        <el-date-picker
            v-model="job.startTime"
            @change="dateChangebirthday2"
            type="datetime"
            value-format="YYYY-MM-DD HH:mm:ss"
            placeholder="Select date and time"
        >
        </el-date-picker>
    </el-form-item>
    <el-form-item label="结束时间">
      <el-date-picker
          value-format="YYYY-MM-DD HH:mm:ss"
          v-model="job.endTime"
          @change="dateChangebirthday3"
          type="datetime"
          placeholder="Select date and time"
      >
      </el-date-picker>
    </el-form-item>
    <el-form-item label="总分">
      <el-input v-model="job.score"></el-input>
    </el-form-item>
    <el-form-item label="部门编号">
      <el-input v-model="job.deptId"></el-input>
    </el-form-item>
    <el-form-item label="备注">
      <el-input v-model="job.remarks"></el-input>
    </el-form-item>
    <el-form-item label="任务状态">
      <el-switch
          v-model="job.status"
          active-text="启用"
          inactive-text="停用"
          active-color="#13ce66"
          inactive-color="#ff4949"
          active-value="0"
          inactive-value="2"/>
    </el-form-item>
    <el-form-item>
      <el-button @click="add()">添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {addJob} from "@/api/job";
import {ElMessage} from "element-plus";
export default {
  name: "AddJob",
  data(){
    return {
      props: {
        label:'Job',
        value:'id',
        createTime: "",
        startTime: "",
        endTime: "",
      },
      jobs:[],
      job:{
        createId:'',
        type:'',
        createTime:'',
        startTime:'',
        endTime:'',
        status:0,
        deptId:'',
        remarks:'',
        score:'',
      }
    }
  },
  methods:{
    async add(){

      const rep = await addJob(this.job)
      if (rep.data.msg) {
        ElMessage({
          type:'success',
          message:'添加成功！'
        })
      }
    },
    dateChangebirthday1(val) {
      this.createTime = val;
      console.log(this.createTime);
    },
    dateChangebirthday2(val) {
      this.startTime = val;
      console.log(this.startTime);
    },
    dateChangebirthday3(val) {
      this.endTime = val;
      console.log(this.endTime);
    }
  }
}
</script>

<style scoped>

</style>